<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>

<body>
    <div id="dv">
        <p>我说p</p>
        <p>我说p</p>
        <p>我说p</p>
        <p>我说p</p>
        <p>我说p</p>
        <p>我说p</p>
    </div>
    <script>
        var odiv = document.getElementById('dv');
        var p = odiv.childNodes;
        var count = 0;
        for (var i = 0; i < p.length; i++) {
            if(p[i].nodeName == 'P'&&p[i].nodeType ==1) {
                p[i].style.backgroundColor = count%2==0? 'red':'pink';
                count++;
            }
        }
    </script>
</body>

</html>